/*
**==============================================================================
**
** Copyright (c) Microsoft Corporation. All rights reserved. See file LICENSE
** for license information.
**
**==============================================================================
*/

#ifndef _wsmanerrorhandling_h
#define _wsmanerrorhandling_h
#include <omi_error/OMI_Error.h>

#define WSE_NS MI_T("http://schemas.xmlsoap.org/ws/2004/08/eventing")

// namespaces from https://msdn.microsoft.com/en-us/library/ee878420.aspx 
// and http://www.dmtf.org/sites/default/files/standards/documents/DSP0227_1.2.0.pdf
#define SOAP_NS_PREFIX MI_T("http://www.w3.org/2003/05/soap-envelope:")
#define WSMAN_NS_PREFIX MI_T("http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd:")
#define WSA_NS_PREFIX MI_T("http://schemas.xmlsoap.org/ws/2004/08/addressing:")
#define WSE_NS_PREFIX MI_T("http://schemas.xmlsoap.org/ws/2004/08/eventing:")
#define WSEN_NS_PREFIX MI_T("http://schemas.xmlsoap.org/ws/2004/09/enumeration:")
#define WXF_NS_PREFIX MI_T("http://schemas.xmlsoap.org/ws/2004/09/transfer:")
#define WSMB_NS_PREFIX MI_T("http://schemas.dmtf.org/wbem/wsman/1/cimbinding.xsd:")

//SOAP FAULT CODE
#define SOAP_FAULT_VERSION_MISMATCH SOAP_NS_PREFIX MI_T("VersionMismatch")
#define SOAP_FAULT_MUST_UNDERSTAND SOAP_NS_PREFIX MI_T("MustUnderstand")
#define SOAP_FAULT_DATA_ENCODING_UNKNOWN SOAP_NS_PREFIX MI_T("DataEncodingUnknown")
#define SOAP_FAULT_RECEIVER SOAP_NS_PREFIX MI_T("Receiver")
#define SOAP_FAULT_SENDER SOAP_NS_PREFIX MI_T("Sender")


//ws-eventing status code (interpreted as fault code in client stack)
#define SUBSCRIPTION_END_STATUS_DELIVERYFAILURE     WSE_NS MI_T("/DeliveryFailure")
#define SUBSCRIPTION_END_STATUS_SOURCEDOWN          WSE_NS MI_T("/SourceShuttingDown")
#define SUBSCRIPTION_END_STATUS_SOURCECANCELLING    WSE_NS MI_T("/SourceCancelling")


//SOAP FAULT SUBCODE -- NOTE SORTED BY STRING which is same as WS-Man spec
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ACCESS_DENIED WSMAN_NS_PREFIX MI_T("AccessDenied")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ACTION_NOT_SUPPORTED WSA_NS_PREFIX MI_T("ActionNotSupported")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ALREADY_EXISTS WSMAN_NS_PREFIX MI_T("AlreadyExists")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_CANNOT_PROCESS_FILTER WSEN_NS_PREFIX MI_T("CannotProcessFilter")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_CANNOT_PROCESS_FILTER WSMAN_NS_PREFIX MI_T("CannotProcessFilter")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_CONCURRENCY WSMAN_NS_PREFIX MI_T("Concurrency")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_DELIVERY_MODE_REQUESTED_UNAVAILABLE WSE_NS_PREFIX MI_T("DeliveryModeRequestedUnavailable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_DELIVERY_REFUSED WSMAN_NS_PREFIX MI_T("DeliveryRefused")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_DESTINATION_UNREACHABLE  WSA_NS_PREFIX MI_T("DestinationUnreachable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENCODING_LIMIT WSMAN_NS_PREFIX MI_T("EncodingLimit")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENDPOINT_UNAVAILABLE WSA_NS_PREFIX MI_T("EndpointUnavilable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTDELIVERTOUNUSABLE WSMAN_NS_PREFIX MI_T("EventDeliverToUnusable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_SOURCE_UNABLE_TO_PROCESS WSE_NS_PREFIX MI_T("EventSourceUnableToProcess")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_FILTER_DIALECT_REQUESTED_UNAVAILABLE WSEN_NS_PREFIX MI_T("FilterDialectRequestedUnavailable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_FILTERING_NOT_SUPPORTED WSE_NS_PREFIX MI_T("FilteringNotSupported")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_FILTERING_NOT_SUPPORTED WSEN_NS_PREFIX MI_T("FilteringNotSupported")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_FILTERING_REQUESTED_UNAVAILABLE WSE_NS_PREFIX MI_T("FilteringRequestedUnavailable")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_FRAGMENT_DIALECT_NOT_SUPPORTED WSMAN_NS_PREFIX MI_T("FragmentDialectNotSupported")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INTERNAL_ERROR WSMAN_NS_PREFIX MI_T("InternalError")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_BOOKMARK WSMAN_NS_PREFIX MI_T("InvalidBookmark")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_INVALID_ENUMERATION_CONTEXT WSEN_NS_PREFIX MI_T("InvalidEnumerationContext")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_INVALID_EXPIRATION_TIME WSE_NS_PREFIX MI_T("InvalidExpirationTime")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_INVALID_EXPIRATION_TIME WSEN_NS_PREFIX MI_T("InvalidExpirationTime")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_INVALID_MESSAGE WSE_NS_PREFIX MI_T("InvalidMessage")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_MESSAGE_INFORMATION_HEADER   WSA_NS_PREFIX MI_T("InvalidMessageInformationHeader")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_OPTIONS WSMAN_NS_PREFIX MI_T("InvalidOptions")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_PARAMETER WSMAN_NS_PREFIX MI_T("InvalidParameter")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_REPRESENTATION WXF_NS_PREFIX MI_T("InvalidRepresentation")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_INVALID_SELECTORS WSMAN_NS_PREFIX MI_T("InvalidSelectors")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_MESSAGE_INFORMATION_HEADER_REQUIRED  WSA_NS_PREFIX MI_T("MessageInformationHeaderRequired")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_NO_ACK WSMAN_NS_PREFIX MI_T("NoAck")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_QUOTA_LIMIT WSMAN_NS_PREFIX MI_T("QuotaLimit")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_SCHEMA_VALIDATION_ERROR WSMAN_NS_PREFIX MI_T("SchemaValidationError")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_TIMED_OUT WSEN_NS_PREFIX MI_T("TimedOut")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_OPERATION_TIMEDOUT WSMAN_NS_PREFIX MI_T("TimedOut")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_UNABLE_TO_RENEW WSE_NS_PREFIX MI_T("UnableToRenew")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_EVENTING_UNSUPPORTED_EXPIRATION_TYPE WSE_NS_PREFIX MI_T("UnsupportedExpirationType")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_ENUMERATE_UNSUPPORTED_EXPIRATION_TYPE WSEN_NS_PREFIX MI_T("UnsupportedExpirationType")
#define SOAP_FAULT_SUBCODE_ERROR_WSMAN_UNSUPPORTED_FEATURE WSMAN_NS_PREFIX MI_T("UnsupportedFeature")

#define SOAP_FAULT_SUBCODE_ERROR_WSMB_POLYMORPHISM_MODE_UNSUPPORTED WSMB_NS_PREFIX MI_T("PolymorphismModeNotSupported")


//WSMAN DETAIL STRINGS -- In order of apearence in WS-Man spec
#define DMTF_FAULT_DETAIL_NS MI_T("http://schemas.dmtf.org/wbem/wsman/1/wsman/")

#define SOAP_FAULT_WSMAN_DETAIL_ACTION_MISMATCH DMTF_FAULT_DETAIL_NS MI_T("faultDetail/ActionMismatch")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_RESOURCE_URI DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidResourceURI")
#define SOAP_FAULT_WSMAN_DETAIL_URI_LIMIT_EXCEEDED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/URILimitExceeded")
#define SOAP_FAULT_WSMAN_DETAIL_MIN_ENVELOPE_SIZE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MinimumEnvelopeSize")
#define SOAP_FAULT_WSMAN_DETAIL_MIN_ENVELOPE_LIMIT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MinimumEnvelopeLimit")
#define SOAP_FAULT_WSMAN_DETAIL_MAX_ENVELOPE_SIZE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxEnvelopeSize")
#define SOAP_FAULT_WSMAN_DETAIL_MAX_ENVELOPE_SIZE_EXCEEDED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxEnvelopeSizeExceeded")
#define SOAP_FAULT_WSMAN_DETAIL_SERVICE_ENVELOPE_LIMIT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/ServiceEnvelopeLimit")
#define SOAP_FAULT_WSMAN_DETAIL_SELECTOR_LIMIT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/SelectorLimit")
#define SOAP_FAULT_WSMAN_DETAIL_OPTION_LIMIT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/OptionLimit")
#define SOAP_FAULT_WSMAN_DETAIL_CHARACTER_SET DMTF_FAULT_DETAIL_NS MI_T("faultDetail/CharacterSet")
#define SOAP_FAULT_WSMAN_DETAIL_UNREPORTABLE_SUCCESS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/UnreportableSuccess")
#define SOAP_FAULT_WSMAN_DETAIL_WHITESPACE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Whitespace")
#define SOAP_FAULT_WSMAN_DETAIL_ENCODING_TYPE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/EncodingType")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_VALUES DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidValues")
#define SOAP_FAULT_WSMAN_DETAIL_UNUSABLE_ADDRESS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/UnusableAddress")
#define SOAP_FAULT_WSMAN_DETAIL_FILTERING_REQUIRED DMTF_FAULT_DETAIL_NS MI_T(":faultDetail/FilteringRequired")
#define SOAP_FAULT_WSMAN_DETAIL_EXPIRED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Expired")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Invalid")
#define SOAP_FAULT_WSMAN_DETAIL_NOT_SUPPORTED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/NotSupported")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_NAME DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidName")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_VALUE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidValue")
#define SOAP_FAULT_WSMAN_DETAIL_TYPE_MISMATCH DMTF_FAULT_DETAIL_NS MI_T("faultDetail/TypeMismatch")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_NAME DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidName")
#define SOAP_FAULT_WSMAN_DETAIL_MISSING_VALUES DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MissingValues")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_NAMESPACE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidNamespace")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_FRAGMENT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidFragment")
#define SOAP_FAULT_WSMAN_DETAIL_SELECTORS_INSUFFICIENT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InsufficientSelectors")
#define SOAP_FAULT_WSMAN_DETAIL_SELECTORS_UNEXPECTED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/UnexpectedSelectors")
#define SOAP_FAULT_WSMAN_DETAIL_SELECTORS_AMBIGUOUS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/AmbiguousSelectors")
#define SOAP_FAULT_WSMAN_DETAIL_SELECTORS_DUPLICATE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/DuplicateSelectors")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_AUTHORIZATION_MODE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/AuthorizationMode")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_ADDRESSING_MODE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/AddressingMode")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_ACK DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Ack")
#define SOAP_FAULT_WSMAN_DETAIL_OPERATION_TIMEOUT  DMTF_FAULT_DETAIL_NS MI_T("faultDetail/OperationTimeout")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_LOCALE  DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Locale")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_ENUMERATION_MODE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/EnumerationMode")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_EXPIRATION_TIME DMTF_FAULT_DETAIL_NS MI_T("faultDetail/ExpirationTime")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_FRAGMENT_TRANSFER DMTF_FAULT_DETAIL_NS MI_T("faultDetail/FragmentLevelAccess")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_DELIVERY_RETRIES DMTF_FAULT_DETAIL_NS MI_T("faultDetail/DeliveryRetries")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_HEARTBEATS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Heartbeats")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_BOOKMARKS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/Bookmarks")
#define SOAP_FAULT_WSMAN_DETAIL_MAX_ELEMENTS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxElements")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_MAXTIME DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxTime")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_MAXENVELOPE_SIZE DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxEnvelopeSize")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_MAXENVELOPE_POLICY DMTF_FAULT_DETAIL_NS MI_T("faultDetail/MaxEnvelopePolicy")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_FILTERING_REQUIRED DMTF_FAULT_DETAIL_NS MI_T("faultDetail/FilteringRequired")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_INSECURE_ADDRESS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InsecureAddress")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_FORMAT_MISMATCH DMTF_FAULT_DETAIL_NS MI_T("faultDetail/FormatMismatch")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_FORMAT_SECURITY_TOKEN DMTF_FAULT_DETAIL_NS MI_T("faultDetail/FormatSecurityToken")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_ASYNCHRONOUS_REQUEST DMTF_FAULT_DETAIL_NS MI_T("faultDetail/AsynchronousRequest")
#define SOAP_FAULT_WSMAN_DETAIL_UNSUPPORTED_FEATURE_OPTIONS DMTF_FAULT_DETAIL_NS MI_T("faultDetail/OptionSet")
#define SOAP_FAULT_WSMAN_DETAIL_INVALID_TIMEOUT DMTF_FAULT_DETAIL_NS MI_T("faultDetail/InvalidTimeout")
#define SOAP_FAULT_WSMAN_DETAIL_POLICY_TOO_COMPLEX DMTF_FAULT_DETAIL_NS MI_T("faultDetail/PolicyTooComplex")
#define SOAP_FAULT_WSMAN_DETAIL_CANNOT_COMPLY_WITH_POLICY DMTF_FAULT_DETAIL_NS MI_T("faultDetail/CannotComplyWithPolicy")

typedef enum _Error_Types
{
    ERROR_UNKNOWN,
    ERROR_WSMAN_SOAP_VERSION_MISMATCH,
    ERROR_WSMAN_SOAP_FAULT_MUST_UNDERSTAND,
    ERROR_ACCESS_DENIED,
    ERROR_WSMAN_ACTION_MISMATCH,
    ERROR_WSMAN_ACTION_NOT_SUPPORTED,
    ERROR_WSMAN_INVALID_ACTIONURI,
    ERROR_WSMAN_ALREADY_EXISTS,
    ERROR_WSMAN_ENUMERATE_CANNOT_PROCESS_FILTER,
    ERROR_WSMAN_CONCURRENCY,
    ERROR_WSMAN_EVENTING_DELIVERY_MODE_REQUESTED_UNAVAILABLE,
    ERROR_WSMAN_DELIVERY_REFUSED,
    ERROR_WSMAN_INVALID_RESOURCE_URI,
    ERROR_WSMAN_RESOURCE_NOT_FOUND,
    ERROR_WSMAN_DESTINATION_UNREACHABLE,
    ERROR_WSMAN_URI_LIMIT,
    ERROR_WSMAN_MIN_ENVELOPE_SIZE,
    ERROR_WSMAN_MAX_ENVELOPE_SIZE,
    ERROR_WSMAN_MAX_ENVELOPE_SIZE_EXCEEDED,
    ERROR_WSMAN_SERVER_ENVELOPE_LIMIT,
    ERROR_WSMAN_SELECTOR_LIMIT,
    ERROR_WSMAN_OPTION_LIMIT,
    ERROR_WSMAN_CHARACTER_SET,
    ERROR_WSMAN_UNREPORTABLE_SUCCESS,
    ERROR_WSMAN_WHITESPACE,
    ERROR_WSMAN_ENCODING_TYPE,
    ERROR_WSMAN_ENCODING_LIMIT,
    ERROR_WSMAN_ENDPOINT_UNAVAILABLE_INVALID_VALUE,
    ERROR_WSMAN_ENDPOINT_UNAVAILABLE,
    ERROR_WSMAN_EVENTING_LOOPBACK_TESTFAILED,
    ERROR_WSMAN_EVENTING_SOURCE_UNABLE_TO_PROCESS,
    ERROR_WSMAN_ENUMERATE_FILTER_DIALECT_REQUESTED_UNAVAILABLE,
    ERROR_WSMAN_EVENTING_FILTERING_NOT_SUPPORTED,
    ERROR_WSMAN_ENUMERATE_FILTERING_NOT_SUPPORTED,
    ERROR_WSMAN_CANNOT_PROCESS_FILTER,
    ERROR_WSMAN_FILTERING_REQUIRED,
    ERROR_WSMAN_EVENTING_FILTERING_REQUESTED_UNAVAILABLE,
    ERROR_INTERNAL_ERROR,
    ERROR_WSMAN_INVALID_TIMEOUT_HEADER,
    ERROR_WSMAN_FRAGMENT_DIALECT_REQUESTED_UNAVAILABLE,
    ERROR_WSMAN_INVALID_FRAGMENT_PATH,
    ERROR_WSMAN_BOOKMARK_EXPIRED,
    ERROR_WSMAN_INVALID_BOOKMARK,
    ERROR_WSMAN_ENUMERATE_INVALID_ENUMERATION_CONTEXT,
    ERROR_WSMAN_EVENTING_INVALID_EXPIRATION_TIME,
    ERROR_WSMAN_ENUMERATE_INVALID_EXPIRATION_TIME,
    ERROR_WSMAN_EVENTING_DELIVERY_MODE_REQUESTED_INVALID,
    ERROR_WSMAN_INVALID_MESSAGE_INFORMATION_HEADER,
    ERROR_WSMAN_OPTIONS_NOT_SUPPORTED,
    ERROR_WSMAN_UNSUPPORTED_FEATURE_OPTIONS,
    ERROR_WSMAN_OPTIONS_INVALID_NAME,
    ERROR_WSMAN_OPTIONS_INVALID_VALUE,
    ERROR_WSMAN_INVALID_OPTIONS,
    ERROR_WSMAN_PARAMETER_TYPE_MISMATCH,
    ERROR_WSMAN_INVALID_PARAMETER_NAME,
    ERROR_WSMAN_INVALID_PARAMETER,
    ERROR_WSMAN_INVALID_XML_VALUES,
    ERROR_WSMAN_INVALID_XML_MISSING_VALUES,
    ERROR_WSMAN_INVALID_XML_NAMESPACE,
    ERROR_WSMAN_INVALID_XML_FRAGMENT,
    ERROR_WSMAN_INVALID_REPRESENTATION,
    ERROR_WSMAN_INSUFFCIENT_SELECTORS,
    ERROR_WSMAN_INVALID_URI_WMI_SINGLETON,
    ERROR_WSMAN_UNEXPECTED_SELECTORS,
    ERROR_WSMAN_SELECTOR_TYPEMISMATCH,
    ERROR_WSMAN_INVALID_SELECTOR_VALUE,
    ERROR_WSMAN_AMBIGUOUS_SELECTORS,
    ERROR_WSMAN_DUPLICATE_SELECTORS,
    ERROR_WSMAN_INVALID_SELECTORS,
    ERROR_WSMAN_MESSAGE_INFORMATION_HEADER_REQUIRED,
    ERROR_WSMAN_NO_ACK,
    ERROR_WSMAN_QUOTA_LIMIT,
    ERROR_WSMAN_QUOTA_MAX_SHELLS,
    ERROR_WSMAN_SCHEMA_VALIDATION_ERROR,
    ERROR_WSMAN_ENUMERATE_TIMED_OUT,
    ERROR_WSMAN_OPERATION_TIMEDOUT,
    ERROR_WSMAN_EVENTING_UNABLE_TO_RENEW,
    ERROR_WSMAN_EVENTING_UNSUPPORTED_EXPIRATION_TYPE,
    ERROR_WSMAN_ENUMERATE_UNSUPPORTED_EXPIRATION_TYPE,
    ERROR_WSMAN_AUTHORIZATION_MODE_NOT_SUPPORTED,
    ERROR_WSMAN_UNSUPPORTED_ADDRESSING_MODE,
    ERROR_WSMAN_ACK_NOT_SUPPORTED,
    ERROR_WSMAN_OPERATION_TIMEOUT_NOT_SUPPORTED,
    ERROR_WSMAN_MUSTUNDERSTAND_ON_LOCALE_UNSUPPORTED,
    ERROR_WSMAN_ENUMERATION_MODE_UNSUPPORTED,
    ERROR_WSMAN_EXPIRATION_TIME_NOT_SUPPORTED,
    ERROR_WSMAN_FRAGMENT_TRANSFER_NOT_SUPPORTED,
    ERROR_WSMAN_DELIVERY_RETRIES_NOT_SUPPORTED,
    ERROR_WSMAN_HEARTBEATS_NOT_SUPPORTED,
    ERROR_WSMAN_BOOKMARKS_NOT_SUPPORTED,
    ERROR_WSMAN_MAX_ELEMENTS_NOT_SUPPORTED,
    ERROR_WSMAN_MAXTIME_NOT_SUPPORTED,
    ERROR_WSMAN_MAXENVELOPE_SIZE_NOT_SUPPORTED,
    ERROR_WSMAN_MAXENVELOPE_POLICY_NOT_SUPPORTED,
    ERROR_WSMAN_FILTERING_REQUIRED_NOT_SUPPORTED,
    ERROR_WSMAN_INSECURE_ADDRESS_NOT_SUPPORTED,
    ERROR_WSMAN_FORMAT_MISMATCH_NOT_SUPPORTED,
    ERROR_WSMAN_FORMAT_SECURITY_TOKEN_NOT_SUPPORTED,
    ERROR_UNKNOWN_FEATURE,
    ERROR_WSMAN_UNSUPPORTED_FEATURE,
    ERROR_WSMAN_EVENTING_MISSING_LOCALE_IN_DELIVERY,
    ERROR_WSMAN_EVENTING_INVALID_HEARTBEAT,
    ERROR_WSMAN_EVENTING_INVALID_MESSAGE,
    ERROR_WSMAN_EVENTING_MISSING_NOTIFYTO,
    ERROR_WSMAN_EVENTING_MISSING_NOTIFYTO_ADDRESSS,
    ERROR_WSMAN_EVENTING_INVALID_NOTIFYTO_ADDRESSS,
    ERROR_WSMAN_INVALID_XML,
    ERROR_WSMAN_LOCALE_NOT_SUPPORTED,
    ERROR_INVALID_PARAMETER_2,               // conflicts with palcommon.h
    ERROR_WSMAN_EVENTING_INCOMPATIBLE_BATCHPARAMS_AND_DELIVERYMODE,
    ERROR_WSMAN_EVENTING_INVALID_ENDTO_ADDRESSS,
    ERROR_WSMAN_EVENTING_SUBSCRIPTIONCLOSED_BYREMOTESERVICE,
    ERROR_WSMAN_EVENTING_DELIVERYFAILED_FROMSOURCE,
    ERROR_WSMAN_EVENTING_SUBSCRIPTION_CANCELLED_BYSOURCE,
    ERROR_WSMAN_EVENTING_INVALID_LOCALE_IN_DELIVERY,
    ERROR_WSMAN_REQUEST_NOT_SUPPORTED_AT_SERVICE,
    ERROR_WSMAN_POLICY_TOO_COMPLEX,
    ERROR_WSMAN_POLICY_CANNOT_COMPLY,
    ERROR_WSMAN_POLYMORPHISM_MODE_UNSUPPORTED
} Error_Types;

typedef struct _Error_Types_Information
{
    Error_Types type;
    MI_Char *name;
} Error_Types_Information;

typedef struct _Soap_Fault_Information
{
    Error_Types WSManErrorCode;
    MI_Char *SoapCode;
    MI_Char *SoapSubcode;
    MI_Char *WSManFaultDetail;
    MI_Uint32 SoapFaultActionURI;
} Soap_Fault_Information;

#define WSMAN_CIMERROR_PROBABLE_CAUSE_UNKNOWN          0
#define WSMAN_CIMERROR_PROBABLE_CAUSE_CONNECTION_ERROR 6
#define WSMAN_CIMERROR_SERVER_LIMITS_EXCEEDED         26
#define WSMAN_CIMERROR_PROBABLE_CAUSE_AUTH_FAILED     60
#define WSMAN_CIMERROR_PROBABLE_CAUSE_TIMEOUT        111
#define WSMAN_CIMERROR_PROBABLE_CAUSE_AUTHENTICATION_FAILURE  117


typedef struct _Probable_Cause_Data
{
    Error_Types type;
    MI_Uint16      probable_cause_id; // From CIM_Error mof
    const MI_Char *description;
    void *alloc_p;                    // If the Probaable_Cause_Data was PAL_Malloc'ed, we can free it using this address. If the address is NULL, 
                                      // this is a pointer to static data 
                                      // If it is PAL_Malloc'ed, the description is expected to be alloced along with the description and vice versa
} Probable_Cause_Data;

BEGIN_EXTERNC

Soap_Fault_Information* GetFaultInformation(MI_Uint32 errorCode);

int ActionIsFault(MI_Uint32 action);

MI_Result GetWsmanErrorFromSoapFault(
    const MI_Char *soapFaultCode, 
    const MI_Char *soapFaultSubcode, 
    const MI_Char *wsmanDetail, 
    Error_Types *wsmanError,
    MI_Char **wsmanErrorStr);

const Probable_Cause_Data* GetWsmanCimError(Error_Types type);

END_EXTERNC

#endif   // !defined(_wsmanerrorhandling_h)
